const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  },
  lintOnSave: false, //关闭语法检查
  //开启代理服务器（方式一）
  /*   devServer: {
    proxy: 'https://www.fastmock.site'
  }, */
  //开启代理服务器（方式二）
  devServer: {
    port: 8888,
    proxy: {
      //配置代理,仅在dev时生效
      "/Mock": {
        //标识需要进行转换请求的url
        target: "https://www.fastmock.site", //服务端域名
        pathRewrite: { "^/Mock": "" },
        // ws: true, //用于支持websocket
        // changeOrigin: true //用于控制请求头中的host值
      },
      "/weather": {
        target: "http://api.k780.com",
        pathRewrite: { "^/weather": "" },
        // ws: true, //用于支持websocket
        // changeOrigin: true //用于控制请求头中的host值
      },
      "/random_img.php": {
        target: "https://img.xjh.me",
        // pathRewrite: { "/random_img.php": "" },
        // https://img.xjh.me/random_img.php
        // ws: true, //用于支持websocket
        // changeOrigin: true //用于控制请求头中的host值
      },
    },
  },
});
